<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>LoveJob-用户管理员</title>
    <link rel="stylesheet" href="media/layui/css/layui.css">
    <script type="application/javascript" src="media/js/jquery.min.js"></script>
    <script type="application/javascript" src="media/layui/layui.js"></script>
</head>
<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>新增管理员</legend>
</fieldset>
<form class="layui-form" action="adminsave.do" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">用户名：</label>
        <div class="layui-input-block">
            <input type="text" name="username" lay-verify="required" onchange="checkName(this)" placeholder="请输入用户名" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号：</label>
        <div class="layui-input-block">
            <input type="text" name="phone" lay-verify="required" onchange="checkName(this)" placeholder="请输入用户名" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">初始密码：</label>
        <div class="layui-input-block">
            <input type="password" name="password" lay-verify="required"  class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" id="btn1" disabled lay-filter="demo1">新增管理员</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script type="application/javascript">
    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(demo1)', function(data){
            layer.msg(JSON.stringify(data.field));
            return true;
        });
    });
    function checkName(obj) {
        $.get("admincheck.do","name="+obj.value,function (obj) {
            if(obj.code==200){
                //可用
                $("#btn1")[0].disabled=false;
            }else{
                //不可用
                $("#btn1")[0].disabled=true;
            }
        })
    }
</script>
</body>
</html>